import 'package:get_it/get_it.dart';
import 'package:learning_content_admin_pannel/root/domain/repositories/learning_content_backup_repository/repository.dart';
import 'package:learning_content_admin_pannel/root/domain/use_cases/backup_learning_content_to_file/use_case.dart';
import 'package:learning_content_admin_pannel/root/domain/use_cases/handle_settings_page_opening_request/use_case.dart';
import 'package:learning_content_admin_pannel/root/domain/use_cases/restore_learning_content_from_file/use_case.dart';
import 'package:learning_content_admin_pannel/root/domain/use_cases/sign_out/use_case.dart';
import 'package:learning_content_admin_pannel/root/infrastructure/repositories/learning_content_backup_repository/repository.dart';
import 'package:learning_content_admin_pannel.core/injection_container.dart' as core_di;

final sl = GetIt.asNewInstance();

Future<void> init() async {
  // use cases

  sl.registerLazySingleton<BackupLearningContentToFile>(() {
    return BackupLearningContentToFileImpl(
      learningContentBackupRepository: sl(),
    );
  });

  sl.registerLazySingleton<HandleSettingsPageOpeningRequest>(() {
    return HandleSettingsPageOpeningRequestImpl(
      handleRootNavigatorPagePushRequest: core_di.sl(),
    );
  });

  sl.registerLazySingleton<RestoreLearningContentFromFile>(() {
    return RestoreLearningContentFromFileImpl(
      learningContentBackupRepository: sl(),
      learningContentRepository: core_di.sl(),
    );
  });

  sl.registerLazySingleton<SignOut>(() {
    return SignOutImpl(
      authApiRepository: core_di.sl(),
      userRepository: core_di.sl(),
      handleAccessCredentialUpdate: core_di.sl(),
    );
  });

  // repositories

  sl.registerLazySingleton<LearningContentBackupRepository>(() {
    return LearningContentBackupRepositoryImpl(
      fileSystemAdapter: core_di.sl(),
    );
  });
}
